﻿''' <summary>
''' 抜取検査記録表
''' </summary>
Public Class clsRandCheckRecords
    ''' <summary>
    ''' データ検索
    ''' </summary>
    ''' <param name="EQUIPNO">設備No.</param>
    ''' <param name="PRODNAME">品名</param>
    ''' <param name="PKG">PKG</param>
    ''' <returns>検索結果</returns>
    Public Function selectRecords(EQUIPNO As String, PRODNAME As String, PKG As String) As DataTable
        Dim szSql As String = ""

        szSql &= "SELECT  * "
        szSql &= "FROM  PER.T_RANDCHECK_RECORDS "
        szSql &= " WHERE EQUIPNO='" & EQUIPNO & "' AND "
        If PRODNAME <> "" Then
            szSql &= " PRODNAME ='" & PRODNAME & "' AND "
        End If
        If PKG <> "" Then
            szSql &= " PKG ='" & PKG & "' AND "
        End If
        szSql &= " 1 = 1 "
        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1)

        Return dt
    End Function
    ''' <summary>
    ''' データ新規
    ''' </summary>
    ''' <param name="EQUIPNO">設備No.</param>
    ''' <param name="PRODNAME">品名</param>
    ''' <param name="PKG">PKG</param>
    ''' <param name="COUNTNUM">個数</param>
    ''' <param name="SUMINVNUM">投入数合計</param>
    Public Sub insertRecords(EQUIPNO As String, PRODNAME As String, PKG As String, COUNTNUM As Integer, SUMINVNUM As Integer)
        Dim szSql As String = ""
        szSql &= "INSERT INTO PER.T_RANDCHECK_RECORDS( "
        szSql &= " EQUIPNO ,  PRODNAME , PKG , COUNTNUM , SUMINVNUM) "
        szSql &= " VALUES ( ? , ? , ? , ? , ? )"

        DBacs.ExecuteUpdateSql(szSql, -1, EQUIPNO, PRODNAME, PKG, COUNTNUM, SUMINVNUM)
    End Sub
    ''' <summary>
    ''' データ修正
    ''' </summary>
    ''' <param name="EQUIPNO">設備No.</param>
    ''' <param name="COUNTNUM">個数</param>
    ''' <param name="SUMINVNUM">投入数合計</param>
    Public Sub updateRecords(EQUIPNO As String, COUNTNUM As Integer, SUMINVNUM As Integer)
        Dim szSql As String = ""

        szSql &= "UPDATE PER.T_RANDCHECK_RECORDS "
        szSql &= "SET"
        szSql &= " COUNTNUM = ?,"
        szSql &= " SUMINVNUM = ? "
        szSql &= "WHERE  EQUIPNO = ? "

        DBacs.ExecuteUpdateSql(szSql, -1, COUNTNUM, SUMINVNUM, EQUIPNO)
    End Sub

    ''' <summary>
    ''' データ削除
    ''' </summary>
    ''' <param name="EQUIPNO">>設備No.</param>
    Public Sub deleteRecords(EQUIPNO As String)
        Dim szSql As String = ""

        szSql &= "DELETE FROM  PER.T_RANDCHECK_RECORDS "
        szSql &= "WHERE  EQUIPNO = ?"

        DBacs.ExecuteUpdateSql(szSql, -1, EQUIPNO)
    End Sub

End Class
